-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use prepended modules instead of undef
for OS-specific code
#18305
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach looks good and makes sense to me, nice work!
I wonder if there's any way to avoid the need for the require
at the bottom of the existing class? That'd be nice if possible.
Yes, that would be very nice, but right now sorbet/sorbet#5025 requires the |
466fdf6
to
4465375
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dduugg! Still have some thoughts about the module
naming/hierarchy but both the discussions and changes can 100% be done post-merge so no feedback here is blocking. Feel free to self-merge whenever you feel happy with it. Great work!
This seems to be causing an error at Homebrew/homebrew-core#191090 |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Relates to #17998
Switches from using
undef
, which results in (suppressed) sorbet errors, with prepended modules.The latest proposal on the thread suggested creating an interface with three implementations, rather than using the generic-OS version in the default implementation, with methods undefined in OS-specific code. In building that out, I noticed that there wasn't a consistent, common interface among the OS variations, specifically in the case of
Formula
.Thus, I've landed on OS extensions written as modules, which are then prepended to be used ahead of the generic implementations. (Note that in some cases, the modules are prepended to the singleton class, which admittedly gets pretty esoteric.)